<?php

use App\Http\Controllers\Shop\Business\AddressController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Shop\Business\BaseController;
use App\Http\Controllers\Shop\Business\EmailController;
use App\Http\Controllers\Shop\Business\CollectionController;
use App\Http\Controllers\Shop\HomeController;
use App\Http\Controllers\Shop\Product\CartController;
use App\Http\Controllers\Shop\Product\ProductController;
use App\Http\Controllers\Shop\Product\OrderController;
use App\Http\Controllers\Shop\Product\TypeController;

/* 
http://www.shop.com/shop/business/base/register
*/
// 父级路由
Route::prefix('business')->group(function(){
    // 子路由
    Route::post('base/register',[BaseController::class,'register']);
    Route::post('base/login',[BaseController::class,'login']);
    Route::post('base/check',[BaseController::class,'check']);
});

// 验证用户登录后才操作的路由
Route::prefix('business')->middleware('Auth')->group(function(){
    Route::post('base/profile',[BaseController::class,'profile']);

    // 收货地址的路由
    Route::post('address/index',[AddressController::class,'index']);
    Route::post('address/add',[AddressController::class,'add']);
    Route::post('address/info',[AddressController::class,'info']);
    Route::post('address/edit',[AddressController::class,'edit']);
    Route::post('address/del',[AddressController::class,'del']);
    Route::post('address/selected',[AddressController::class,'selected']);

    // 邮箱路由
    Route::post('email/send',[EmailController::class,'send']);
    Route::post('email/check',[EmailController::class,'check']);

    Route::post('collection/index',[CollectionController::class,'index']);
    Route::post('collection/del',[CollectionController::class,'del']);
});

// 不带前缀并且不需要登录的路由
Route::post('index/index',[HomeController::class,'index']);

// 商品相关的路由，不需要登录
Route::prefix('product')->group(function(){
    Route::post('product/index',[ProductController::class,'index']);
    Route::post('product/info',[ProductController::class,'info']);
    Route::post('type/index',[TypeController::class,'index']);
    Route::post('type/product',[TypeController::class,'product']);
});
Route::prefix('product')->middleware('Auth')->group(function(){
    Route::post('product/collection',[ProductController::class,'collection']);
    Route::post('product/comment',[ProductController::class,'comment']);
        // 购物车相关路由
    Route::post('cart/add',[CartController::class,'add']);
    Route::post('cart/index',[CartController::class,'index']);
    Route::post('cart/update',[CartController::class,'update']);
    Route::post('cart/del',[CartController::class,'del']);
    Route::post('cart/info',[CartController::class,'info']);
    Route::post('cart/default',[CartController::class,'default']);
        
    // 订单相关的路由
    Route::post('order/confirm',[OrderController::class,'confirm']);
    Route::post('order/index',[OrderController::class,'index']);
    Route::post('order/pay',[OrderController::class,'pay']);
    Route::post('order/detail',[OrderController::class,'detail']);

});
